#include "common_includes.h"
#include "common_monitor.h"

#if SYS_MONITOR_FUNC


COM_TASK_DEF(ComMonitor);

#if defined(SYS_MONITOR_1S_POLING) && (SYS_MONITOR_1S_POLING == 1)
static void common_monitor_1s_polling(void)
{

}
#endif


#if defined(SYS_MONITOR_500MS_POLING) && (SYS_MONITOR_500MS_POLING == 1)
static void common_monitor_500ms_polling(void)
{

}
#endif

static void common_monitor_msg_handler(Task task, MessageId id, Message msg)
{
    UNUSED(task);
	msg = msg;
	
    switch (id)
    {

#if defined(SYS_MONITOR_1S_POLING) && (SYS_MONITOR_1S_POLING == 1)
		case COMMON_MONITOR_1S_POLLING:
		{
			common_monitor_1s_polling();	
			MessageSendLater(COM_GET_TASK(ComMonitor), COMMON_MONITOR_1S_POLLING, NULL, D_SEC(1));
			break;
		}		
#endif

#if defined(SYS_MONITOR_500MS_POLING) && (SYS_MONITOR_500MS_POLING == 1)
		case COMMON_MONITOR_500MS_POLLING:
		{
			common_monitor_1s_polling();	
			MessageSendLater(COM_GET_TASK(ComMonitor), COMMON_MONITOR_1S_POLLING, NULL, D_SEC(1));
			break;
		}		
#endif

		default :break; 
    }
}

bool common_monitor_init(void)
{
	COM_TASK_INIT(ComMonitor, common_monitor_msg_handler);

#if defined(SYS_MONITOR_1S_POLING) && (SYS_MONITOR_1S_POLING == 1)
	MessageSendLater(COM_GET_TASK(ComMonitor), COMMON_MONITOR_1S_POLLING, NULL, D_SEC(1));
#endif

#if defined(SYS_MONITOR_500MS_POLING) && (SYS_MONITOR_500MS_POLING == 1)
	MessageSendLater(COM_GET_TASK(ComMonitor), COMMON_MONITOR_500MS_POLLING, NULL, 500);
#endif

    return TRUE;
}

#endif

